package com.bw.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.checkerframework.checker.units.qual.A;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @TableName user
 */
@TableName(value = "user")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {
    /**
     *
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     *
     */
    @NotBlank(message = "用户名不为空")
    private String name;


    /**
     *
     */
    @NotBlank(message = "密码不为空")
    //密码必须包含字母、数字


    @Length(min = 6,message = "长度大于6位")
    @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d).+$", message = "密码必须包含字母、数字且长度大于6位")
    private String password;


    /**
     *
     */
    private String salt;

    /**
     * 1 房东  0 客户
     */
    private Integer role;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}